package com.seckill.search.feign;
import com.seckill.goods.pojo.Sku;
import com.seckill.search.pojo.SkuInfo;
import com.seckill.util.Result;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

import java.io.IOException;
import java.util.List;

@FeignClient(name = "seckill-search",path = "/api/search")
public interface SkuInfoFeign {

    /***
     * 增量操作  ->删除索引   type=3
     *           ->修改索引   type=2
     *           ->添加索引   type=1
     */
    @PostMapping(value = "/modify/{type}")
    Result modify(@PathVariable(value = "type")Integer type, @RequestBody SkuInfo skuInfo);

    /***
     * 增量操作  ->删除索引   type=3
     *           ->修改索引   type=2
     *           ->添加索引   type=1
     */
    @PostMapping(value = "/modify/sku/{type}")
    Result modifySku(@PathVariable(value = "type")Integer type, @RequestBody Sku sku);

    @GetMapping(value = "/del/all")
    void deleteAll();

    /***
     * 增量操作
     */
    @PostMapping(value = "/addIndex")
    Result addIndex(@RequestBody Sku sku) throws IOException;

    /***
     * 增量操作
     */
    @PostMapping(value = "/batch/addIndex")
    Result batchAddIndex(@RequestBody List<Sku> skus) throws IOException;

    /**
     * 根据id删除文档数据
     * @param id
     * @return
     */
    @DeleteMapping(value = "/{id}")
    Result deleteById(@PathVariable("id")String id);
}